let timeFormat = {
	fixed: function (timeStamp = false, format='Y-m-d H:i:s') {
		timeStamp = new Date(timeStamp * 1000 || new Date());
		format = format.replace(/Y/, timeStamp.getFullYear());
		format = format.replace(/m/, (timeStamp.getMonth() + 1 < 10 ? '0' + (timeStamp.getMonth() + 1) : timeStamp.getMonth() + 1));
		format = format.replace(/d/, timeStamp.getDate() < 10 ? '0' + timeStamp.getDate() : timeStamp.getDate());
		format = format.replace(/H/, timeStamp.getHours() < 10 ? '0' + timeStamp.getHours() : timeStamp.getHours());
		format = format.replace(/i/, timeStamp.getMinutes() < 10 ? '0' + timeStamp.getMinutes() : timeStamp.getMinutes());
		format = format.replace(/s/, timeStamp.getSeconds() < 10 ? '0' + timeStamp.getSeconds() : timeStamp.getSeconds());
		return format;
	},
	before: function (timeStamp) {
		let thisTimeStamp = Math.round(new Date() / 1000);
		let intervalSeconds = thisTimeStamp - timeStamp;
		if(intervalSeconds < 10){
			return '刚刚';
		} else if (intervalSeconds < 60){
			return intervalSeconds + '秒前';
		} else if (intervalSeconds < 3600){
			return Math.floor(intervalSeconds/60) + '分钟前';
		} else if (intervalSeconds < 86400){
			return Math.floor(intervalSeconds/3600) + '小时前';
		} else if (intervalSeconds > (86400*7) && intervalSeconds < (86400*14)){
			return Math.floor(intervalSeconds/(86400*7)) + '周前';
		} else if (intervalSeconds < (86400*30)){
			return Math.floor(intervalSeconds/86400) + '天前';
		}
		return this.fixed(thisTimeStamp);
	}
}
export default timeFormat